package gttp.nspa.client;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.Editor.Path;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;

public class HumanList implements IsWidget {

    static interface HumanProps extends PropertyAccess<Human> {

        @Path("id")
        ModelKeyProvider<Human> key();

        @Path("name")
        LabelProvider<Human> nameLabel();

        ValueProvider<Human, String> name();

        ValueProvider<Human, String> address();

        ValueProvider<Human, String> phone();

        ValueProvider<Human, String> email();
    }

    private static final HumanProps props = GWT.create(HumanProps.class);

    public Widget asWidget() {
        ColumnConfig<Human, String> nameCol = new ColumnConfig<Human, String>(props.name(), 50, "Tên");
        ColumnConfig<Human, String> addrCol = new ColumnConfig<Human, String>(props.address(), 150, "Địa chỉ");
        ColumnConfig<Human, String> phoneCol = new ColumnConfig<Human, String>(props.phone(), 75, "Điện thoại");
        ColumnConfig<Human, String> emailCol = new ColumnConfig<Human, String>(props.email(), 75, "Email");

        List<ColumnConfig> l = new ArrayList<ColumnConfig>();
        l.add(nameCol);
        l.add(addrCol);
        l.add(phoneCol);
        l.add(emailCol);
        ColumnModel cm = new ColumnModel(l);

        return null;
    }

}
